using System;
using System.Collections.Generic;
using System.Text;
using XPStudio.UMS.Model;
using System.Data;
using System.Data.SqlClient;

namespace XPStudio.UMS.BLL
{
    public class UserBLL
    {
        

        public static int AddUser(UserModel u)
        {
            return UMS.DAL.UserDAL.Add(u);
        }

        public static DataSet GetUsers()
        {
            return UMS.DAL.UserDAL.GetUsers();
        }

        public static DataSet GetUsers(int usertype)
        {
            return UMS.DAL.UserDAL.GetUsers(usertype);
        }

        public static void DelUser(int userid)
        {
            DAL.UserDAL.DelUser(userid);
        }

        public static int ValidateUser(int userid, string password, int passwordformat)
        {
            UserModel u = new UserModel();
            u.UserID = userid;
            u.Password = password;
            u.PasswordFormat = passwordformat;
            return DAL.UserDAL.ValidateUser(userid,password, passwordformat);
        }

        public static int ValidateUser(string username, string password, int passwordformat)
        {
            UserModel u = new UserModel();
            u.UserName = username;
            u.Password = password;
            u.PasswordFormat = passwordformat;
            return DAL.UserDAL.ValidateUser(username, password, passwordformat);
        }

        public static bool Login(UserModel u)
        {
            return DAL.UserDAL.Login(u);
        }

        public static bool Logout(int userid, DateTime dt)
        {
            return DAL.UserDAL.Logout(userid,dt);
        }

        public static bool Logout(string username , DateTime dt)
        {
            return DAL.UserDAL.Logout(username,dt);
        }

        public static UserModel GetUser(int userid)
        {
            return DAL.UserDAL.GetUser(userid);
        }

        public static UserModel GetUser(string username)
        {
            return DAL.UserDAL.GetUser(username);
        }

        public static bool ResetPassword(int userid, string newpassword, int passwordformat, string newsalt)
        {
            return DAL.UserDAL.ResetPassword(userid, newpassword, passwordformat, newsalt);
        }

        public static bool ChangePassword(UserModel user, string newpassword, int passwordformat, string newsalt )
        {
            return DAL.UserDAL.ChangePassword(user, newpassword, passwordformat,newsalt);
        }

        public static string GetUserRoleList(int userid)
        {
            return DAL.UserDAL.GetUserRoleList(userid);
        }
    }
}
